

var e = require;
var t = module;
var n = exports;
var o,
    i =
        (this && this.__extends) ||
        ((o = function (e, t) {
            return (o =
                Object.setPrototypeOf ||
                ({__proto__: []} instanceof Array &&
                    function (e, t) {
                        e.__proto__ = t;
                    }) ||
                function (e, t) {
                    for (var n in t) Object.prototype.hasOwnProperty.call(t, n) && (e[n] = t[n]);
                })(e, t);
        }),
        function (e, t) {
            function n() {
                this.constructor = e;
            }
            o(e, t), (e.prototype = null === t ? Object.create(t) : ((n.prototype = t.prototype), new n()));
        }),
    r =
        (this && this.__decorate) ||
        function (e, t, n, o) {
            var i,
                r = arguments.length,
                a = r < 3 ? t : null === o ? (o = Object.getOwnPropertyDescriptor(t, n)) : o;
            if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) a = Reflect.decorate(e, t, n, o);
            else
                for (var s = e.length - 1; 0 <= s; s--)
                    (i = e[s]) && (a = (r < 3 ? i(a) : 3 < r ? i(t, n, a) : i(t, n)) || a);
            return 3 < r && a && Object.defineProperty(t, n, a), a;
        };
Object.defineProperty(n, "__esModule", {value: !0});
var a,
    s = e("events"),
    c = e("sound"),
    l = e("vibrate"),
    u = e("guide-manager"),
    p = e("player-info"),
    t = cc._decorator,
    e = t.ccclass,
    t = t.property,
    e =
        ((a = cc.Component),
        i(h, a),
        (h.prototype.onLoad = function () {
            (this.bgMask.active = !1), this.node.getComponent(cc.Widget).updateAlignment(), this.reset();
        }),
        (h.prototype.show = function (e, t) {
            var n = this;
            this.bgMask.active = !0;
            var o = p.playerInfo.getGuideStepCount();
			this.unscheduleAllCallbacks(), (this.curStep = e), (this.content.active = !0);
            var t = t.convertToWorldSpaceAR(cc.Vec2.ZERO),
                i = this.node.convertToNodeSpaceAR(t);
            (this.hand.active = this.curStep !== u.GuideStep.target),
                (this.button.getComponent(cc.Button).interactable = this.curStep != u.GuideStep.target),
                (this.targetBtn.getComponent(cc.Button).interactable = this.curStep == u.GuideStep.target);
            for (var r = 0; r < o; r++)
                if (1 << (r + 1) === e) {
                    var a = this.maskSprites[r];
                    this.button.setPosition(i),
                        this.hand.setPosition(i.x + this.handOffPositions[r].x, i.y + this.handOffPositions[r].y),
                        this.curStep === u.GuideStep.merge && ((i.y = i.y + 148 + 20), (i.x = i.x - 3)),
                        this.mask.setPosition(i),
                        this.bg.setPosition(-i.x, -i.y),
                        this.bg.setContentSize(this.node.getContentSize()),
                        this.mask.setContentSize(a.getRect().width, a.getRect().height),
                        this.button.setContentSize(a.getRect().width, a.getRect().height),
                        (this.mask.getComponent(cc.Mask).spriteFrame = a),
                        (this.labelBg.node.active = !((5 <= r && r <= 8) || 10 === r)),
                        (this.labelBg.spriteFrame = this.labelSprites[r]);
                    var s = 0.5 * this.labelBg.node.getContentSize().height + 10 + 0.5 * a.getRect().height,
                        a = 0;
                    this.curStep === u.GuideStep.target && ((s = -s), (a = -155)),
                        this.labelBg.node.setPosition(i.x + a, i.y + s),
                        this.curStep === u.GuideStep.merge && this.labelBg.node.setPosition(0, i.y + s);
                    break;
                }
            this.curStep === u.GuideStep.target &&
                this.scheduleOnce(function () {
                    n.onContentCall();
                }, 2);
        }),
        (h.prototype.reset = function () {
			cc.error(888888);
            (this.content.active = !1), (this.hand.active = !1);
        }),
        (h.prototype.onCall = function () {
            switch (
                (1,
                (this.button.getComponent(cc.Button).interactable = !1),
                (this.targetBtn.getComponent(cc.Button).interactable = !1),
                this.curStep)
            ) {
                case u.GuideStep.choose:
                    s.operEvent.emit({action: s.default.cellTouch, data: {cellIdx: 0, isChoose: !1}}),
                        p.playerInfo.useGuide(this.curStep),
                        this.reset();
                    break;
                case u.GuideStep.place:
                    s.operEvent.emit({action: s.default.cellTouch, data: {cellIdx: 2, isChoose: !1}}),
                        p.playerInfo.useGuide(this.curStep);
                    break;
                case u.GuideStep.merge:
                    c.sound.play(c.Sound.MERGE),
                        l.vibrate.play(l.VibrateNewType.LONG),
                        s.operEvent.emit({action: s.default.merge, data: null}),
                        p.playerInfo.useGuide(this.curStep),
                        this.reset();
                    break;
                case u.GuideStep.deal:
                    c.sound.play(c.Sound.GIVECOIN),
                        l.vibrate.play(l.VibrateNewType.SHORT),
                        s.operEvent.emit({action: s.default.deal, data: {guide: !0}}),
                        this.reset(),
                        p.playerInfo.useGuide(this.curStep);
                    break;
                case u.GuideStep.choose1:
                    s.operEvent.emit({action: s.default.cellTouch, data: {cellIdx: 0, isChoose: !1}}),
                        p.playerInfo.useGuide(this.curStep),
                        this.reset();
                    break;
                case u.GuideStep.place1:
                    s.operEvent.emit({action: s.default.cellTouch, data: {cellIdx: 1, isChoose: !1}}),
                        p.playerInfo.useGuide(this.curStep);
                    break;
                case u.GuideStep.choose2:
                    s.operEvent.emit({action: s.default.cellTouch, data: {cellIdx: 2, isChoose: !1}}),
                        p.playerInfo.useGuide(this.curStep),
                        this.reset();
                    break;
                case u.GuideStep.place2:
                    s.operEvent.emit({action: s.default.cellTouch, data: {cellIdx: 1, isChoose: !1}}),
                        p.playerInfo.useGuide(this.curStep);
                    break;
                case u.GuideStep.merge1:
                    c.sound.play(c.Sound.MERGE),
                        l.vibrate.play(l.VibrateNewType.LONG),
                        s.operEvent.emit({action: s.default.merge, data: null}),
                        p.playerInfo.useGuide(this.curStep),
                        this.reset();
                    break;
                case u.GuideStep.deal1:
                    c.sound.play(c.Sound.GIVECOIN),
                        l.vibrate.play(l.VibrateNewType.SHORT),
                        u.GuideManager.ins.setIsGuide(!1),
                        p.playerInfo.useGuide(this.curStep),
                        s.operEvent.emit({action: s.default.deal, data: null}),
                        this.reset(),
                        (this.bgMask.active = !1);(this.node.active = !1);
            }
        }),
        (h.prototype.onContentCall = function () {
            this.unscheduleAllCallbacks(),
                (this.button.getComponent(cc.Button).interactable = !1),
                (this.targetBtn.getComponent(cc.Button).interactable = !1),
                this.curStep === u.GuideStep.target &&
                    (p.playerInfo.useGuide(this.curStep), s.operEvent.emit({action: s.default.guideDeal, data: {}}));
        }),
        (h.prototype.showWeakMerge = function (e) {
            this.bgMask.active = !1;
            (e = e.convertToWorldSpaceAR(cc.Vec2.ZERO)), (e = this.node.convertToNodeSpaceAR(e));
            this.hand.setPosition(e.x + 60, e.y), (this.hand.active = !0);
        }),
        (h.prototype.showWeakDeal = function (e) {
            this.bgMask.active = !1;
            (e = e.convertToWorldSpaceAR(cc.Vec2.ZERO)), (e = this.node.convertToNodeSpaceAR(e));
            this.hand.setPosition(e.x + 60, e.y), (this.hand.active = !0);
        }),
        (h.prototype.hideHand = function () {
            this.hand.active = !1;
        }),
        r([t(cc.Node)], h.prototype, "bgMask", void 0),
        r([t(cc.Node)], h.prototype, "content", void 0),
        r([t(cc.Node)], h.prototype, "mask", void 0),
        r([t(cc.Node)], h.prototype, "bg", void 0),
        r([t(cc.Node)], h.prototype, "hand", void 0),
        r([t(cc.Node)], h.prototype, "button", void 0),
        r([t(cc.Sprite)], h.prototype, "labelBg", void 0),
        r([t(cc.Node)], h.prototype, "targetBtn", void 0),
        r([t(cc.SpriteFrame)], h.prototype, "labelSprites", void 0),
        r([t(cc.SpriteFrame)], h.prototype, "maskSprites", void 0),
        r([t(cc.Vec2)], h.prototype, "handOffPositions", void 0),
        r([e], h));
function h() {
    var e = (null !== a && a.apply(this, arguments)) || this;
    return (
        (e.bgMask = null),
        (e.content = null),
        (e.mask = null),
        (e.bg = null),
        (e.hand = null),
        (e.button = null),
        (e.labelBg = null),
        (e.targetBtn = null),
        (e.labelSprites = []),
        (e.maskSprites = []),
        (e.handOffPositions = []),
        (e.curStep = null),
        e
    );
}
n.default = e;
